package com.future.hedongjun.mine.order;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.flyco.tablayout.SlidingTabLayout;
import com.future.baselib.adapter.FragmentAdapter;
import com.future.hedongjun.R;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * A simple {@link Fragment} subclass.
 */
public class MallOrderFragment extends Fragment {


    @BindView(R.id.tabLayout)
    SlidingTabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    Unbinder unbinder;

    private String[] titles = {"全部", "待付款", "待发货", "待收货", "退款审核中"};

    public MallOrderFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_mall_order, container, false);
        unbinder = ButterKnife.bind(this, view);
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(OrderListFragment.getInstance(OrderListFragment.TYPE_ALL));
        fragments.add(OrderListFragment.getInstance(OrderListFragment.TYPE_WAIT_PAY));
        fragments.add(OrderListFragment.getInstance(OrderListFragment.TYPE_WAIT_SEND));
        fragments.add(OrderListFragment.getInstance(OrderListFragment.TYPE_WAIT_GET));
        fragments.add(OrderListFragment.getInstance(OrderListFragment.TYPE_TUIKUAN_ING));
        viewPager.setAdapter(new FragmentAdapter(getChildFragmentManager(), fragments));
        tabLayout.setViewPager(viewPager, titles);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
